package com.yks.demo.lvcr.democlient.task;

import com.yks.demo.lvcr.democlient.service.ITaskService;
import com.yks.demo.lvcr.democlient.utils.HttpUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;

@Component
public class Task1 {
    private static java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(Task1.class.toString());
    static {LOG.setLevel(Level.INFO);}

    @Autowired
    private ITaskService taskService;

    @Scheduled(cron = "0/5 * * * * ?")
    public void dotask(){
        try {
            System.out.println("task1开始执行定时任务 now time:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            System.out.println("task1当前线程"+Thread.currentThread());
            String rtnStr = taskService.doJob();
            System.out.println("task1 rtnStr:" + rtnStr);
            System.out.println("task1结束执行定时任务 now time:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        }catch (Exception e){
           e.printStackTrace();
        }
    }
}
